<div class="layui-form" lay-filter="layuiadmin-form-admin" id="layuiadmin-form-admin" style="padding: 20px 30px 0 0;">

    <div class="layui-form-item">
        <label class="layui-form-label">所属上级</label>
        <div class="layui-input-block">
            <div id="demo2" class="xm-select-demo"></div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">部门名称</label>
        <div class="layui-input-block">
            <input type="text" name="name" required lay-verify="name" placeholder="请输入部门名称" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">负责人</label>
        <div class="layui-input-block">
            <div id="demo3" class="xm-select-demo"></div>
        </div>
    </div>
    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="LAY-user-back-submit" id="LAY-user-back-submit" value="确认">
    </div>
</div>
<script src="/static/admin/layui/layui.js"></script>
<script src="/static/admin/js/xm-select.js"></script>
<script>
    layui.config({
        base: '/static/admin/' //静态资源所在路径
    }).extend({
        index: 'lib/index', //主入口模块
    }).use(['index', 'form'], function () {
        var $ = layui.$, form = layui.form;
        form.render();
        form.verify({
            username: function (value) {
                if (value.length < 5) {
                    return '用户名至少得5个字符';
                }
            }, nickname: function (value) {
                if (value.length < 2) {
                    return '昵称至少2位字符';
                }
            }
            , pass: [
                /^[\S]{6,12}$/
                , '密码必须6到12位，且不能出现空格'
            ]
            , phone: [/^1[3|4|5|7|8]\d{9}$/, '手机必须11位，只能是数字or格式不对！']
            , email: [/^[a-z0-9._%-]+@([a-z0-9-]+\.)+[a-z]{2,4}$|^1[3|4|5|7|8]\d{9}$/, '邮箱格式不对']
        });
        $.ajax({
            url: "{:url('admin/dept')}",
            type: 'post',
            dataType: 'json',
            success: function (res) {
                xmSelect.render({
                    el: '#demo2',
                    radio: true,
                    name:'pid',
                    filterable: true,
                    data: res
                })
            }
        });
        $.ajax({
            url: "{:url('flow/adminTree')}",
            type: 'post',
            dataType: 'json',
            success: function (res) {
                xmSelect.render({
                    el: '#demo3',
                    radio: true,
                    name:'manager',
                    filterable: true,
                    data: res
                })
            }
        });
    })
</script>

